<template>
    <div>
        <div class="title">{{ $t('stm.dubiousTransaction.transactionReporte') }}</div>
        <bfe-form :model="formObj" ref="formObj" label-position="top">
            <vxe-table :data="formObj.list" ref="modlOprtInfoRef" border class="tableList">
                <vxe-table-column :title="$t('stm.branchTransReport.seq')" width='80'>
                    <template #default="{ row, rowIndex }">
                        {{ rowIndex + 1 }}
                    </template>
                </vxe-table-column>
                <vxe-table-column :title="$t('stm.branchTransReport.orgName')" width='80'>
                    <template #default="{ row, rowIndex }">
                        <div>{{ formObj.list[rowIndex].rptOrgName }}</div>
                    </template>
                </vxe-table-column>
                <vxe-table-column :title="$t('stm.branchTransReport.rptDate')" width='80'>
                    <template #default="{ row, rowIndex }">
                        <div v-if="type !== 'view'">{{ date }}</div>
                        <div v-else>{{ row.rptpd }}</div>
                    </template>
                </vxe-table-column>
                <vxe-table-column :title="$t('stm.dubiousTransaction.transactionReporte')">
                    <vxe-table-column :title="$t('stm.dubiousTransaction.inRptDate')">
                        <vxe-table-column :title="$t('stm.dubiousTransaction.sysAlertGenerated')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                <template #default="{ row, rowIndex }">
                                    <bfe-form-item :rules="formRules.txnDnum"
                                        :prop="`list.${rowIndex}.dtpoGenWarnQanty`">
                                        <bfe-input v-if="type !== 'view'"
                                            v-model="formObj.list[rowIndex].dtpoGenWarnQanty" :maxlength="12"
                                            @input="(val) => handleInputChange(val, rowIndex, row, 'dtpoGenWarnQanty', 'begofToEopGenSysWarnQanty')"
                                            :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                        <div v-else>{{ formObj.list[rowIndex].dtpoGenWarnQanty }}</div>
                                    </bfe-form-item>
                                </template>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.Closed')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                <template #default="{ row, rowIndex }">
                                    <bfe-form-item :rules="formRules.txnDnum"
                                        :prop="`list.${rowIndex}.dtpoComplSurvyWarnQanty`">
                                        <bfe-input v-if="type !== 'view'" @change="handleDChange(rowIndex)"
                                            v-model="formObj.list[rowIndex].dtpoComplSurvyWarnQanty" :maxlength="12"
                                            @input="(val) => handleInputChange(val, rowIndex, row, 'dtpoComplSurvyWarnQanty', 'begofToEopComplSurvySysWarnQanty')"
                                            :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                        <div v-else>{{ formObj.list[rowIndex].dtpoComplSurvyWarnQanty }}</div>
                                    </bfe-form-item>
                                </template>
                            </vxe-table-column>
                        </vxe-table-column>

                        <vxe-table-column :title="$t('stm.dubiousTransaction.durationClosed')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.in30d')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.otherTxnDnum"
                                            :prop="`list.${rowIndex}.dtpoComplSurvyNearWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].dtpoComplSurvyNearWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].dtpoComplSurvyNearWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.to90d')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.otherTxnDnum"
                                            :prop="`list.${rowIndex}.dtpoComplSurvyMidWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].dtpoComplSurvyMidWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].dtpoComplSurvyMidWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.out91d')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.otherTxnDnum"
                                            :prop="`list.${rowIndex}.dtpoComplSurvyFarWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].dtpoComplSurvyFarWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].dtpoComplSurvyFarWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>

                        <vxe-table-column :title="$t('stm.dubiousTransaction.Outstanding')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                <template #default="{ row, rowIndex }">
                                    <bfe-form-item :rules="formRules.txnDnum"
                                        :prop="`list.${rowIndex}.eopNotComplSurvyWarnQanty`">
                                        <bfe-input v-if="type !== 'view'" @change="handleDCTwohange(rowIndex)"
                                            v-model="formObj.list[rowIndex].eopNotComplSurvyWarnQanty" :maxlength="12"
                                            :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                        <div v-else>{{ formObj.list[rowIndex].eopNotComplSurvyWarnQanty }}</div>
                                    </bfe-form-item>
                                </template>
                            </vxe-table-column>
                        </vxe-table-column>


                        <vxe-table-column :title="$t('stm.dubiousTransaction.durOutstanding')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.in30d')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.otherTwoTxnDnum"
                                            :prop="`list.${rowIndex}.eopNotComplSurvyNearWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].eopNotComplSurvyNearWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].eopNotComplSurvyNearWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.to90d')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.otherTwoTxnDnum"
                                            :prop="`list.${rowIndex}.eopNotComplSurvyMidWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].eopNotComplSurvyMidWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].eopNotComplSurvyMidWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.out91d')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.otherTwoTxnDnum"
                                            :prop="`list.${rowIndex}.eopNotComplSurvyFarWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].eopNotComplSurvyFarWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].eopNotComplSurvyFarWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.suspiciousActClosed')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.document')" width="160">
                                <template #default="{ row, rowIndex }">
                                    <bfe-form-item :rules="formRules.txnDnum"
                                        :prop="`list.${rowIndex}.dtpoComplSurvySspcsClueQanty`">
                                        <bfe-input v-if="type !== 'view'"
                                            v-model="formObj.list[rowIndex].dtpoComplSurvySspcsClueQanty"
                                            @input="(val) => handleInputChange(val, rowIndex, row, 'dtpoComplSurvySspcsClueQanty', 'begofToEopComplSurvySspcsClueQanty')"
                                            :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                        <div v-else>{{ formObj.list[rowIndex].dtpoComplSurvySspcsClueQanty }}</div>
                                    </bfe-form-item>
                                </template>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.RFIsFromForeign')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.document')" width="160">
                                <template #default="{ row, rowIndex }">
                                    <bfe-form-item :rules="formRules.txnDnum"
                                        :prop="`list.${rowIndex}.dtpoPcsgOvseaAgcbkAmlRclEnqrQanty`">
                                        <bfe-input v-if="type !== 'view'"
                                            v-model="formObj.list[rowIndex].dtpoPcsgOvseaAgcbkAmlRclEnqrQanty"
                                            :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                        <div v-else>{{ formObj.list[rowIndex].dtpoPcsgOvseaAgcbkAmlRclEnqrQanty }}</div>
                                    </bfe-form-item>
                                </template>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.SARsSubmitted')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.sysGenerated')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.dtpoSbmsnSysWarnQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].dtpoSbmsnSysWarnQanty" :maxlength="12"
                                                @input="(val) => handleInputChange(val, rowIndex, row, 'dtpoSbmsnSysWarnQanty', 'begofToEopSbmsnSspcsSysWarnQanty')"
                                                :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].dtpoSbmsnSysWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.manuallyCreated')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.document')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.dtpoSbmsnSspcsClueQanty`">
                                            <bfe-input v-if="type !== 'view'"
                                                v-model="formObj.list[rowIndex].dtpoSbmsnSspcsClueQanty" :maxlength="12"
                                                @input="(val) => handleInputChange(val, rowIndex, row, 'dtpoSbmsnSspcsClueQanty', 'begofToEopSbmsnSspcsSspcsClueQanty')"
                                                :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].dtpoSbmsnSspcsClueQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>
                    </vxe-table-column>
                    <vxe-table-column :title="$t('stm.dubiousTransaction.YearToEnd')">
                        <vxe-table-column :title="$t('stm.dubiousTransaction.sysAlert')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                <template #default="{ row, rowIndex }">
                                    <bfe-form-item :rules="formRules.txnDnum"
                                        :prop="`list.${rowIndex}.begofToEopGenSysWarnQanty`">
                                        <bfe-input v-if="type !== 'view'" :disabled="true"
                                            v-model="formObj.list[rowIndex].begofToEopGenSysWarnQanty" :maxlength="12"
                                            :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                        <div v-else>{{ formObj.list[rowIndex].begofToEopGenSysWarnQanty }}</div>
                                    </bfe-form-item>
                                </template>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.alertsClosed')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.sysGenerated')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopComplSurvySysWarnQanty`">
                                            <bfe-input v-if="type !== 'view'" :disabled="true"
                                                v-model="formObj.list[rowIndex].begofToEopComplSurvySysWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].begofToEopComplSurvySysWarnQanty
                                            }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.manuallyCreated')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.document')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopComplSurvySspcsClueQanty`">
                                            <bfe-input v-if="type !== 'view'" :disabled="true"
                                                v-model="formObj.list[rowIndex].begofToEopComplSurvySspcsClueQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{ formObj.list[rowIndex].begofToEopComplSurvySspcsClueQanty
                                            }}
                                            </div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.alertedFocal')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.directCustomer')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopComplSurvyOurbkCusQanty`">
                                            <bfe-tooltip v-if="type !== 'view'" class="item" effect="dark"
                                                :content="$t('stm.branchTransReport.message1')" placement="top">
                                                <bfe-input 
                                                    v-model="formObj.list[rowIndex].begofToEopComplSurvyOurbkCusQanty"
                                                    :maxlength="12"
                                                    :placeholder="$t('stm.branchTransReport.message1')"></bfe-input>
                                            </bfe-tooltip>

                                            <div v-else>{{ formObj.list[rowIndex].begofToEopComplSurvyOurbkCusQanty
                                            }}
                                            </div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.NonCusEntity')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopComplSurvyNonCusEntQanty`">
                                            <bfe-tooltip v-if="type !== 'view'" class="item" effect="dark"
                                                :content="$t('stm.branchTransReport.message2')" placement="top">
                                                <bfe-input 
                                                    v-model="formObj.list[rowIndex].begofToEopComplSurvyNonCusEntQanty"
                                                    :maxlength="12"
                                                    :placeholder="$t('stm.branchTransReport.message2')"></bfe-input>
                                            </bfe-tooltip>

                                            <div v-else>{{ formObj.list[rowIndex].begofToEopComplSurvyNonCusEntQanty
                                            }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.alertsSARs')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.sysGenerated')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopSbmsnSspcsSysWarnQanty`">
                                            <bfe-input v-if="type !== 'view'" :disabled="true"
                                                v-model="formObj.list[rowIndex].begofToEopSbmsnSspcsSysWarnQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{
                                                formObj.list[rowIndex].begofToEopSbmsnSspcsSysWarnQanty }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.manuallyCreated')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.document')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopSbmsnSspcsSspcsClueQanty`">
                                            <bfe-input v-if="type !== 'view'" :disabled="true"
                                                v-model="formObj.list[rowIndex].begofToEopSbmsnSspcsSspcsClueQanty"
                                                :maxlength="12" :placeholder="$t('stm.common.pleaseInput')"></bfe-input>
                                            <div v-else>{{
                                                formObj.list[rowIndex].begofToEopSbmsnSspcsSspcsClueQanty }}
                                            </div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>
                        <vxe-table-column :title="$t('stm.dubiousTransaction.alertedFocal')">
                            <vxe-table-column :title="$t('stm.dubiousTransaction.directCustomer')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopSbmsnSspcsOurbkCusQanty`">

                                            <bfe-tooltip v-if="type !== 'view'" class="item" effect="dark"
                                                :content="$t('stm.branchTransReport.message3')" placement="top">
                                                <bfe-input 
                                                    v-model="formObj.list[rowIndex].begofToEopSbmsnSspcsOurbkCusQanty"
                                                    :maxlength="12"
                                                    :placeholder="$t('stm.branchTransReport.message3')"></bfe-input>
                                            </bfe-tooltip>
                                            <div v-else>{{
                                                formObj.list[rowIndex].begofToEopSbmsnSspcsOurbkCusQanty
                                            }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                            <vxe-table-column :title="$t('stm.dubiousTransaction.NonCusEntity')">
                                <vxe-table-column :title="$t('stm.dubiousTransaction.ct')" width="160">
                                    <template #default="{ row, rowIndex }">
                                        <bfe-form-item :rules="formRules.txnDnum"
                                            :prop="`list.${rowIndex}.begofToEopSbmsnSspcsNonCusEntQanty`">
                                            <bfe-tooltip v-if="type !== 'view'" class="item" effect="dark"
                                                :content="$t('stm.branchTransReport.message4')" placement="top">
                                                <bfe-input
                                                    v-model="formObj.list[rowIndex].begofToEopSbmsnSspcsNonCusEntQanty"
                                                    :maxlength="12"
                                                    :placeholder="$t('stm.branchTransReport.message4')"></bfe-input>
                                            </bfe-tooltip>
                                            <div v-else>{{
                                                formObj.list[rowIndex].begofToEopSbmsnSspcsNonCusEntQanty
                                            }}</div>
                                        </bfe-form-item>
                                    </template>
                                </vxe-table-column>
                            </vxe-table-column>
                        </vxe-table-column>
                    </vxe-table-column>
                </vxe-table-column>
                <!--<vxe-table-column :title="$t('stm.dubiousTransaction.operate')" width="120" v-if="type !== 'view'">
                    <template #default="{ row, rowIndex }">
                        <bfe-button type="text" @click="delList(rowIndex)"
                            v-if="formObj.list && formObj.list.length !== 1">{{$t('stm.common.deleteText')}}</bfe-button>
                        <bfe-button type="text" @click="addList"
                            v-if="!formObj.list || formObj.list.length === 0">{{$t('stm.common.add')}}</bfe-button>
                    </template>
                </vxe-table-column>-->
            </vxe-table>
        </bfe-form>
        <!--<vxe-pager border :current-page="tablePage.pageNo" :page-size="tablePage.pageSize" :total="tablePage.total"
            :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
            @page-change="handlePageChange"
            :lang="currentLanguage">
        </vxe-pager>-->
    </div>
</template>

<script>
import { mapState } from "vuex";

export default {
    props: {
        type: {
            type: String,
            default: "",
        },
        date: {
            type: String,
            default: "",
        },
        reqOrgNo: {
            type: String,
            default: null,
        },
    },
    data(props) {
        return {
            formObj: {
                list: [],
            },
            // 分页
            tablePage: {
                pageNo: 1,
                pageSize: 10,
                total: 0,
            },
            allNumList: [],
            prevValues: {},
            formRules: {
                txnDnum: [{
                    validator: (rule, value, callback) => {
                        if (value === '' || value === null || value === undefined) {
                            // 如果字段非必填，空值通过；如果是必填，请在 rules 中加 required: true
                            return callback();
                        }
                        const str = String(value).trim();
                        const regex = /^(?:0|[1-9]\d*)$/;

                        if (regex.test(str)) {
                            callback();
                        } else {
                            callback(new Error(this.$t('stm.branchTransReport.pleaseInputInt')))
                        }
                    },
                    required: false,
                    trigger: 'blur'
                }],
                otherTxnDnum: [{
                    validator: (rule, value, callback) => {
                        const reg = /^(?:[0-9]\d*)$/
                        console.log(value, reg.test(value), '笔数校验')
                        if (value && !reg.test(value)) {
                            callback(new Error(this.$t('stm.branchTransReport.pleaseInputInt')))
                        }
                        // 校验
                        // 提取 rowIndex
                        const match = rule.field.match(/list\.(\d+)\.(dtpoComplSurvyNearWarnQanty|dtpoComplSurvyMidWarnQanty|dtpoComplSurvyFarWarnQanty)/);
                        if (!match) return callback();

                        const rowIndex = parseInt(match[1]);
                        const row = this.formObj.list[rowIndex];

                        const a = Number(row.dtpoComplSurvyNearWarnQanty) || 0; // 30内
                        const b = Number(row.dtpoComplSurvyMidWarnQanty) || 0; // 30-90
                        const c = Number(row.dtpoComplSurvyFarWarnQanty) || 0;  // 90以上
                        const d = Number(row.dtpoComplSurvyWarnQanty) || 0;  // 总数
                        if ((a + c + b) > d) {
                            callback(new Error(this.$t('stm.dubiousTransaction.outMax')))
                        }
                        callback()
                    },
                    required: false,
                    trigger: 'blur'
                }],
                otherTwoTxnDnum: [{
                    validator: (rule, value, callback) => {
                        const reg = /^(?:[0-9]\d*)$/
                        console.log(value, reg.test(value), '笔数校验')
                        if (value && !reg.test(value)) {
                            callback(new Error(this.$t('stm.branchTransReport.pleaseInputInt')))
                        }
                        // 校验
                        // 提取 rowIndex
                        const match = rule.field.match(/list\.(\d+)\.(eopNotComplSurvyNearWarnQanty|eopNotComplSurvyMidWarnQanty|eopNotComplSurvyFarWarnQanty)/);
                        if (!match) return callback();

                        const rowIndex = parseInt(match[1]);
                        const row = this.formObj.list[rowIndex];

                        const a = Number(row.eopNotComplSurvyNearWarnQanty) || 0; // 30内
                        const b = Number(row.eopNotComplSurvyMidWarnQanty) || 0; // 30-90
                        const c = Number(row.eopNotComplSurvyFarWarnQanty) || 0;  // 90以上
                        const d = Number(row.eopNotComplSurvyWarnQanty) || 0;  // 总数
                        if ((a + c + b) > d) {
                            callback(new Error(this.$t('stm.dubiousTransaction.outMax')))
                        }
                        callback()
                    },
                    required: false,
                    trigger: 'blur'
                }],
            }
        };
    },
    computed: {
        ...mapState({
            language: (state) => state.base.language,
            userInfo: (state) => state.base.userInfo,
        }),
        currentLanguage() {
            return this.language || 'zh_CN'
        },
    },
    created() {
        this.initData()
    },
    methods: {
        // 初始化数据
        initData() {
            const params = {
                optCode: "STM002GET1809",
                payload: {
                    rptOrgNo: this.reqOrgNo,
                    rptpd: this.date,
                    queryFrom: this.type === 'view' ? 'query' : this.type
                },
                pageInfo: {
                    pageNo: 1,
                    pageSize: 10,
                },
            };
            this.$p2svr(this.$api["_01_TSTM02MONRPT1800"], "RequestPoAuth", {
                ...params,
            }).then((res) => {
                console.log(res.payload, "大额特定交易");
                if (!res.payload || !Array.isArray(res.payload) || res.payload.length === 0) {
                    if (this.type !== "view") {
                        this.formObj.list = [{
                            rptOrgName: this.userInfo.userAhrOrgName,
                            dtpoGenWarnQanty: '',
                            dtpoComplSurvyWarnQanty: '',
                            dtpoComplSurvyNearWarnQanty: '',
                            dtpoComplSurvyMidWarnQanty: '',
                            dtpoComplSurvyFarWarnQanty: '',
                            eopNotComplSurvyWarnQanty: '',
                            eopNotComplSurvyNearWarnQanty: '',
                            eopNotComplSurvyMidWarnQanty: '',
                            eopNotComplSurvyFarWarnQanty: '',
                            dtpoComplSurvySspcsClueQanty: '',
                            dtpoPcsgOvseaAgcbkAmlRclEnqrQanty: '',
                            dtpoSbmsnSysWarnQanty: '',
                            dtpoSbmsnSspcsClueQanty: '',
                            begofToEopGenSysWarnQanty: '',
                            begofToEopComplSurvySysWarnQanty: '',
                            begofToEopComplSurvySspcsClueQanty: '',
                            begofToEopComplSurvyOurbkCusQanty: '',
                            begofToEopComplSurvyNonCusEntQanty: '',
                            begofToEopSbmsnSspcsSysWarnQanty: '',
                            begofToEopSbmsnSspcsSspcsClueQanty: '',
                            begofToEopSbmsnSspcsOurbkCusQanty: '',
                            begofToEopSbmsnSspcsNonCusEntQanty: '',
                        }];
                        this.tablePage.total = 1
                    }
                } else {
                    if (this.type === 'add') {
                        console.log(this.userInfo, 'this.userInfo');

                        // 时候只保存加总数据 不回显
                        this.formObj.list = [{
                            rptOrgName: this.userInfo.userAhrOrgName,
                            dtpoGenWarnQanty: '',
                            dtpoComplSurvyWarnQanty: '',
                            dtpoComplSurvyNearWarnQanty: '',
                            dtpoComplSurvyMidWarnQanty: '',
                            dtpoComplSurvyFarWarnQanty: '',
                            eopNotComplSurvyWarnQanty: '',
                            eopNotComplSurvyNearWarnQanty: '',
                            eopNotComplSurvyMidWarnQanty: '',
                            eopNotComplSurvyFarWarnQanty: '',
                            dtpoComplSurvySspcsClueQanty: '',
                            dtpoPcsgOvseaAgcbkAmlRclEnqrQanty: '',
                            dtpoSbmsnSysWarnQanty: '',
                            dtpoSbmsnSspcsClueQanty: '',
                            begofToEopGenSysWarnQanty: '',
                            begofToEopComplSurvySysWarnQanty: '',
                            begofToEopComplSurvySspcsClueQanty: '',
                            begofToEopComplSurvyOurbkCusQanty: '',
                            begofToEopComplSurvyNonCusEntQanty: '',
                            begofToEopSbmsnSspcsSysWarnQanty: '',
                            begofToEopSbmsnSspcsSspcsClueQanty: '',
                            begofToEopSbmsnSspcsOurbkCusQanty: '',
                            begofToEopSbmsnSspcsNonCusEntQanty: '',
                        }];
                        this.tablePage.total = 1
                        this.allNumList = res.payload
                    } else {
                        this.formObj.list = res.payload.map((item, index) => {
                            if (!this.prevValues[index + 1]) {
                                this.$set(this.prevValues, index + 1, {});
                            }

                            // 然后整体替换它的内容（保留原有字段 or 完全覆盖）
                            this.$set(this.prevValues, index + 1, {
                                ...this.prevValues[index + 1], // 保留已有字段（可选）
                                dtpoGenWarnQanty: item.dtpoGenWarnQanty,
                                dtpoComplSurvyWarnQanty: item.dtpoComplSurvyWarnQanty,
                                dtpoComplSurvySspcsClueQanty: item.dtpoComplSurvySspcsClueQanty,
                                dtpoSbmsnSysWarnQanty: item.dtpoSbmsnSysWarnQanty,
                                dtpoSbmsnSspcsClueQanty: item.dtpoSbmsnSspcsClueQanty,
                            });
                            return {
                                ...item,
                                rptTp: Number(item.rptTp),
                                id: index + 1,
                                // begofToEopGenSysWarnQanty: Number(item.begofToEopGenSysWarnQanty) - Number(item.dtpoGenWarnQanty),
                                // begofToEopComplSurvySysWarnQanty: Number(item.begofToEopComplSurvySysWarnQanty) - Number(item.dtpoComplSurvyWarnQanty),
                                // begofToEopComplSurvySspcsClueQanty: Number(item.begofToEopComplSurvySspcsClueQanty) - Number(item.dtpoComplSurvySspcsClueQanty),
                                // begofToEopSbmsnSspcsSysWarnQanty: Number(item.begofToEopSbmsnSspcsSysWarnQanty) - Number(item.dtpoSbmsnSysWarnQanty),
                                // begofToEopSbmsnSspcsSspcsClueQanty: Number(item.begofToEopSbmsnSspcsSspcsClueQanty) - Number(item.dtpoSbmsnSspcsClueQanty)
                            }
                        });
                        this.tablePage.total = res.pageInfo ? res.pageInfo.total : 0
                        this.tablePage.pageNo = res.pageInfo ? res.pageInfo.pageNo : 1
                        this.tablePage.pageSize = res.pageInfo ? res.pageInfo.pageSize : 10
                    }

                }
            });
        },
        // 分页
        handlePageChange({ currentPage, pageSize }) {
            this.tablePage.pageNo = currentPage
            this.tablePage.pageSize = pageSize
            this.initData()
        },
        // 删除
        delList(index) {
            this.formObj.list.splice(index, 1)
            if (this.tablePage.total > 0) {
                this.tablePage.total = this.tablePage.total - 1
            }
        },
        // 新增
        addList() {
            this.formObj.list.push({
                rptOrgName: this.userInfo.userAhrOrgName,
                dtpoGenWarnQanty: '',
                dtpoComplSurvyWarnQanty: '',
                dtpoComplSurvyNearWarnQanty: '',
                dtpoComplSurvyMidWarnQanty: '',
                dtpoComplSurvyFarWarnQanty: '',
                eopNotComplSurvyWarnQanty: '',
                eopNotComplSurvyNearWarnQanty: '',
                eopNotComplSurvyMidWarnQanty: '',
                eopNotComplSurvyFarWarnQanty: '',
                dtpoComplSurvySspcsClueQanty: '',
                dtpoPcsgOvseaAgcbkAmlRclEnqrQanty: '',
                dtpoSbmsnSysWarnQanty: '',
                dtpoSbmsnSspcsClueQanty: '',
                begofToEopGenSysWarnQanty: '',
                begofToEopComplSurvySysWarnQanty: '',
                begofToEopComplSurvySspcsClueQanty: '',
                begofToEopComplSurvyOurbkCusQanty: '',
                begofToEopComplSurvyNonCusEntQanty: '',
                begofToEopSbmsnSspcsSysWarnQanty: '',
                begofToEopSbmsnSspcsSspcsClueQanty: '',
                begofToEopSbmsnSspcsOurbkCusQanty: '',
                begofToEopSbmsnSspcsNonCusEntQanty: '',
            })
            this.tablePage.total = this.tablePage.total + 1
        },
        handleDChange(rowIndex) {
            // 手动触发 a、b、c 三个字段的校验
            // 假设你有办法获取到表单实例，比如 this.$refs.form
            // 这里以伪代码示意
            ['dtpoComplSurvyNearWarnQanty', 'dtpoComplSurvyMidWarnQanty', 'dtpoComplSurvyFarWarnQanty'].forEach(field => {
                const prop = `list.${rowIndex}.${field}`;
                // 手动触发表单校验
                this.$refs.formObj.validateField(prop);
            });
        },
        handleDCTwohange(rowIndex) {
            // 手动触发 a、b、c 三个字段的校验
            // 假设你有办法获取到表单实例，比如 this.$refs.form
            // 这里以伪代码示意
            ['eopNotComplSurvyNearWarnQanty', 'eopNotComplSurvyMidWarnQanty', 'eopNotComplSurvyFarWarnQanty'].forEach(field => {
                const prop = `list.${rowIndex}.${field}`;
                // 手动触发表单校验
                this.$refs.formObj.validateField(prop);
            });
        },
        handleInputChange(val, rowIndex, row, name, targetName) {
            const id = rowIndex + 1
            if (val === null || val === undefined) {
                // 如果字段非必填，空值通过；
                return
            }

            const str = String(val).trim();
            const regex = /^(?:0|[1-9]\d*)$/;
            console.log(id, rowIndex, 1);

            if (str === '' || regex.test(str)) {
                const currentVal = Number(str);

                console.log(this.prevValues, 2);
                const prevVal = this.prevValues[id] && this.prevValues[id][name]
                    ? this.prevValues[id][name]
                    : 0;
                const delta = currentVal - prevVal;
                console.log(delta, this.formObj.list, 3);
                // 更新 targetName：加上差值
                const newTargetVal = (Number(this.formObj.list[rowIndex][targetName]) || 0) + delta;
                this.$set(this.formObj.list[rowIndex], targetName, newTargetVal);

                // 更新缓存
                console.log(this.prevValues[id], 4);
                // 更新缓存
                if (!this.prevValues[id]) {
                    this.$set(this.prevValues, id, { [name]: currentVal });
                } else {
                    this.$set(this.prevValues[id], [name], currentVal); // 存原始输入（空串或数字字符串）
                }
            }
        },
        validateForm() {
            let flag = false
            this.$refs.formObj.validate((ok) => {
                if (ok) {
                    flag = true
                } else {
                }
            })
            return flag
        },
    },
};
</script>


<style lang="less" scoped>
.title {
    font-size: 18px;
    color: rgba(0, 0, 0, 0.85);
    font-weight: 600;
}

.tableList {
    /deep/.giop-form-item {
        margin-bottom: 0;
    }

    /deep/.cell {
        padding: 6px 10px;
    }

    /deep/.giop-form-item__error {
        position: relative;
        padding: 0 0 4px;
    }

    /deep/.giop-input--small .giop-input__inner {
        height: 30px !important;
    }

    /deep/.giop-form-item {
        margin-bottom: 0;
    }

    /deep/.giop-cascader {
        width: 100%;
    }

    /deep/.giop-cascader--small .giop-cascader__label {
        line-height: 36px;
    }
}
</style>